<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理 - 易买网</title>
<link type="text/css" rel="stylesheet" href="../css/style.css" />
<script type="text/javascript" src="../scripts/function-manage.js"></script>
<script type="text/javascript" src="../scripts/jquery-1.8.3.js"></script>
</head>
<body>
<div class="main">
	<h2>添加商品</h2>
	<div class="manage">
		<form action="createProductServlet" enctype="multipart/form-data" method="post">
			<table class="form">
				<tr>
					<td class="field">商品名称：</td>
					<td><input type="text" class="text" name="productName" value="" /></td>
				</tr>
				<tr>
					<td class="field">所属分类：</td>
					<td>
						<select id="parentId" name="parentId" onchange="pchange();">
							<option class="pid" value="0">-请选择-</option>
							<c:forEach items="${plist}" var="v">
								<option value="${v.epcid}">${v.epcname}</option>
							</c:forEach>
						</select>
						<select id="sonId" name="sonId">
							<option class="sid" value="0">-请选择-</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="field">商品图片：</td>
					<td><input type="file" class="text" name="photo" /></td>
				</tr>
				<tr>
					<td class="field">商品价格：</td>
					<td><input type="text" class="text tiny" name="productPrice" /> 元</td>
				</tr>
				<%--<tr>
                    <td class="field">品牌：</td>
                    <td><input type="text" class="text" name="productName" /></td>
                </tr>--%>
				<tr>
					<td class="field">库存：</td>
					<td><input type="text" class="text tiny" name="productNum" /></td>
				</tr>
				<tr>
					<td></td>
					<td><label class="ui-blue"><input type="submit" name="submit" value="添加" /></label></td>
				</tr>
			</table>
		</form>
	</div>
</div>
</body>
</html>
<script>
	function pchange(){
        $(".pid[value=0]").remove();
        $.ajax({
            type:"POST",
            url:"GetCategoryByPidServlet",
            dataType:"JSON",
            data:{
                pid:$("#parentId").val()
            },
            success:function (data) {
                $(".sid").remove();
                $.each(data, function (index, obj) {
                    var v2 = "<option class='sid' value='"+ obj.epcid +"'>"+ obj.epcname +"</option>";
                    $("#sonId").append(v2);
                });
            }
        });
    }
</script>
